# Author: Sanmu
# CreatTime: 2024/10/24
# Descriptior: 描述

from base_page.base_page import BasePage
from conf.set_conf import read_conf

class LoginPage(BasePage):
    username = ('id','loginName')
    password = ('id','password')
    button = ('xpath','//button[@type="submit"]')
    inputCode = ('id','inputCode')
    code_png = ('xpath','//img[@data-v-4f5798c5]')
    is_login = ('xpath','//div[text()="登录失败"]')
    def login(self,path,name,pwd):
        self.open(path)
        self.input(*self.username,name)
        self.input(*self.password,pwd)
        self.wait(2)
        while True:
            # 获取验证码
            code = self.cor_code(*self.code_png)
            # 输入验证码
            self.input(*self.inputCode, code)
            self.click(*self.button)
            try:
                self.locator(*self.is_login)
                # 获取验证码
                code = self.cor_code(*self.code_png)
                # 输入验证码
                self.input(*self.inputCode, code)
                self.click(*self.button)
            except:
                break
        self.wait(5)





